import socket

# 初始化客户端socket
client_socket = socket.socket()
# 进行连接服务器端
client_socket.connect(("127.0.0.1", 8887))
# 发送信息到端
client_socket.send("hi,我是客户端".encode())
# 接受服务器端的信息
msg = client_socket.recv(1024).decode()
while msg:
    if msg != '':
        print("接受到服务器端的数据：", msg)
    sendmsg = input("请输入发送给服务端的数据：")
    if sendmsg == 'bye':
        break
    client_socket.send(sendmsg.encode())
    print("发送成功，等待服务端信息")
    msg = client_socket.recv(1024).decode()
client_socket.close()
